function clonehmm (feature_len,word)

% file_name

fid_clone=fopen('HMM0/hmmdefs','w');
fid_proto=fopen('HMM0/proto');

% copy the first three lines
if fid_clone >0 & fid_proto>0
    tline_proto=fgetl(fid_proto); fprintf(fid_clone, tline_proto); fprintf(fid_clone,'\n');
    tline_proto=fgetl(fid_proto); fprintf(fid_clone, tline_proto); fprintf(fid_clone,'\n');
    tline_proto=fgetl(fid_proto); fprintf(fid_clone, tline_proto); fprintf(fid_clone,'\n');
    fclose(fid_proto);
    fclose(fid_clone);
    
    % write varFloors to hmmdefs
    
    fid_clone = fopen('HMM0/hmmdefs','a+');
    
    fid_var=fopen('HMM0/vFloors');
    while 1
        tline_var=fgetl(fid_var);
        if tline_var==-1
            break
        end
        fprintf(fid_clone,tline_var);
        fprintf(fid_clone,'\n');
    end
    fclose(fid_var);
    fclose(fid_clone);
    % clone hmms
    
    fid_clone = fopen('HMM0/hmmdefs','a+');
    
    for i=1:length(word)
        fid_proto=fopen('HMM0/proto');
        fgetl(fid_proto);fgetl(fid_proto);fgetl(fid_proto);
        while 1
            tline_proto=fgetl(fid_proto);
            if (tline_proto==-1)
                break
            else
                tline_proto=strrep(tline_proto,'proto',word{i});
                fprintf(fid_clone, tline_proto);
                fprintf(fid_clone, '\n');
            end
        end
        fprintf(fid_clone,'\n');
        fclose(fid_proto);
    end
    fclose(fid_clone);
    
    fid_clone = fopen('HMM0/hmmdefs','a+');
    
    % construct file (sil model)
    
    
    mean_value=0.0;
    variance_value=1.0;
    mean_value=repmat(mean_value,1,feature_len);
    variance_value=repmat(variance_value,1,feature_len);
    fprintf(fid_clone,'~h "sil"\n');
    fprintf(fid_clone,'<BEGINHMM>\n');
    fprintf(fid_clone,'<NUMSTATES> 3\n');
    
    for i=2:2
        fprintf(fid_clone,'<STATE> %d\n',i);
        fprintf(fid_clone,'<MEAN> %d\n',feature_len);
        fprintf(fid_clone,'   %5.1f',mean_value');
        fprintf(fid_clone,'\n <VARIANCE> %d\n',feature_len);
        fprintf(fid_clone,'   %5.1f',variance_value');
        fprintf(fid_clone,'\n');
    end
    
    transition_matrix=zeros(3,3);
    transition_matrix(1,2)=1.0;
    transition_matrix(2,2)=0.7;
    transition_matrix(2,3)=0.3;
    
    fprintf(fid_clone,'<TRANSP> %d\n', 3);
    for i=1:3
        for j=1:3
            fprintf(fid_clone, '%5.1f', transition_matrix(i,j));
        end
        fprintf(fid_clone,'\n');
    end
    
    fprintf(fid_clone,'<ENDHMM>\n');
    
    fclose(fid_clone);
else
    errordlg('Your data seems to be corrupt, please re-do the data preparation.',...
        'Corrupt Files!');
end